package top.aigoo.project01.enums;

/**
 * 枚使用枚举表述常量数据字典
 * Created by  Mr.OYSHUO.欧阳大叔(1642302522@qq.com) on 2021/8/9
 */
public enum LocalAuthStateEnum {
    LOGINFAIL(-1, "密码或帐号输入有误"),
    SUCCESS(0, "操作成功"),
    NULL_AUTH_INFO(-1006, "注册信息为空"),
    ONLY_ONE_ACCOUNT(-1007,"最多只能绑定一个本地帐号");

    private int state;

    private String stateInfo;


    private LocalAuthStateEnum(int state, String stateInfo) {
        this.state = state;
        this.stateInfo = stateInfo;
    }

    /**
     * 依据传入的state编码返回相应的enum值
     */
    public static LocalAuthStateEnum stateOf(int state) {
        for (LocalAuthStateEnum stateEnum : values()) {
            if (stateEnum.getState() == state) {
                return stateEnum;
            }
        }
        return null;
    }

    public int getState() {
        return state;
    }

    public String getStateInfo() {
        return stateInfo;
    }
}
